package com.base.mybaseproject.demo.Map;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.OvershootInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.mybaseproject.R;

public class MapCallOut extends LinearLayout {

	private ImageView iv;
	private TextView tv;

	public MapCallOut(Context context) {
		super(context);
		LayoutInflater.from(context).inflate(R.layout.map_call_out_widget, this, true);
		iv = (ImageView) findViewById(R.id.map_call_out_iv);
		tv = (TextView) findViewById(R.id.map_call_out_tv);
		
//		iv.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				tv.setText(getTag() + "");
//			}
//		});

	}

	public MapCallOut(Context context, AttributeSet attrs) {
		super(context, attrs);
		LayoutInflater.from(context).inflate(R.layout.map_call_out_widget, this, true);
		iv = (ImageView) findViewById(R.id.map_call_out_iv);
		tv = (TextView) findViewById(R.id.map_call_out_tv);
	}

	public void transitionIn() {

		ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f,
				Animation.RELATIVE_TO_SELF, 1f);
		scaleAnimation.setInterpolator(new OvershootInterpolator(1.2f));
		scaleAnimation.setDuration(250);

		AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1f);
		alphaAnimation.setDuration(200);

		AnimationSet animationSet = new AnimationSet(false);

		animationSet.addAnimation(scaleAnimation);
		animationSet.addAnimation(alphaAnimation);

		startAnimation(animationSet);

	}

	public void setText(String str) {
		tv.setText(str);
	}

	public void setOnClickVideo(final String string) {
		iv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				tv.setText(string);
			}
		});
	}
}
